import { Button,Input} from 'antd'
import {useState} from 'react'

export  function TodoInput(props){
    const {addTodo} = props
    const [text, setText] = useState('')
    function handleChangeText(event) {
        setText(event.target.value)
    }
    const add = ()=>{
        if(!text)return;
        addTodo({task:text,id:new Date().getTime()})
        setText('')
    }
    return (
        <div>
            <Input  style={{width:'200px'}} value={text} onChange={handleChangeText}/>
            <Button onClick={add}>add</Button>
        </div>
    )
}

export default TodoInput